winsafe\comctl\structs/
structs_other.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use std::marker::PhantomData;
4
5use crate::co;
6use crate::comctl::privs::*;
7use crate::decl::*;
8use crate::kernel::{ffi_types::*, privs::*};
9use crate::prelude::*;
10
11/// [`BUTTON_IMAGELIST`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-button_imagelist)
12/// struct.
13#[repr(C)]
14pub struct BUTTON_IMAGELIST {
15	pub himl: HIMAGELIST,
16	pub margin: RECT,
17	pub uAlign: co::BIA,
18}
19
20/// [`BUTTON_SPLITINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-button_splitinfo)
21/// struct.
22#[repr(C)]
23pub struct BUTTON_SPLITINFO {
24	pub mask: co::BCSIF,
25	pub himlGlyph: HIMAGELIST,
26	pub uSplitStyle: co::BCSS,
27	pub size: SIZE,
28}
29
30/// [`COLORSCHEME`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-colorscheme)
31/// struct.
32#[repr(C)]
33pub struct COLORSCHEME {
34	dwSize: u32,
35	pub clrBtnHighlight: COLORREF,
36	pub clrBtnShadow: COLORREF,
37}
38
39impl_default!(COLORSCHEME, dwSize);
40
41/// [`DATETIMEPICKERINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-datetimepickerinfo)
42/// struct.
43#[repr(C)]
44pub struct DATETIMEPICKERINFO {
45	cbSize: u32,
46	pub rcCheck: RECT,
47	pub stateCheck: co::STATE_SYSTEM,
48	pub rcButton: RECT,
49	pub stateButton: co::STATE_SYSTEM,
50	pub hwndEdit: HWND,
51	pub hwndUD: HWND,
52	pub hwndDropDown: HWND,
53}
54
55impl_default!(DATETIMEPICKERINFO, cbSize);
56
57/// [`EDITBALLOONTIP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-editballoontip)
58/// struct.
59#[repr(C)]
60pub struct EDITBALLOONTIP<'a, 'b> {
61	cbStruct: u32,
62	pszTitle: *mut u16,
63	pszText: *mut u16,
64	pub ttiIcon: co::TTI,
65
66	_pszTitle: PhantomData<&'a mut u16>,
67	_pszText: PhantomData<&'b mut u16>,
68}
69
70impl_default!(EDITBALLOONTIP, cbStruct, 'a, 'b);
71
72impl<'a, 'b> EDITBALLOONTIP<'a, 'b> {
73	pub_fn_string_ptr_get_set!('a, pszTitle, set_pszTitle);
74	pub_fn_string_ptr_get_set!('b, pszText, set_pszText);
75}
76
77/// [`HDITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-hditemw)
78/// struct.
79#[repr(C)]
80pub struct HDITEM<'a> {
81	pub mask: co::HDI,
82	pub cxy: i32,
83	pszText: *mut u16,
84	pub hbm: HBITMAP,
85	cchTextMax: i32,
86	pub fmt: co::HDF,
87	pub lParam: isize,
88	pub iImage: i32,
89	pub iOrder: i32,
90	pub typeFilter: co::HDFT,
91	pub pvFilter: *mut std::ffi::c_void,
92	pub state: co::HDIS,
93
94	_pszText: PhantomData<&'a mut u16>,
95}
96
97impl_default!(HDITEM, 'a);
98
99impl<'a> HDITEM<'a> {
100	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
101}
102
103/// [`HDHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-hdhittestinfo)
104/// struct.
105#[repr(C)]
106#[derive(Default)]
107pub struct HDHITTESTINFO {
108	pub pt: POINT,
109	pub flags: co::HHT,
110	pub iItem: i32,
111}
112
113/// [`HDLAYOUT`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-hdlayout)
114/// struct.
115#[repr(C)]
116pub struct HDLAYOUT<'a, 'b> {
117	prc: *mut RECT,
118	pwpos: *mut WINDOWPOS,
119
120	_prc: PhantomData<&'a mut RECT>,
121	_pwpos: PhantomData<&'b mut WINDOWPOS>,
122}
123
124impl_default!(HDLAYOUT, 'a, 'b);
125
126impl<'a, 'b> HDLAYOUT<'a, 'b> {
127	pub_fn_ptr_get_set!('a, prc, set_prc, RECT);
128	pub_fn_ptr_get_set!('b, pwpos, set_pwpos, WINDOWPOS);
129}
130
131/// [`INITCOMMONCONTROLSEX`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-initcommoncontrolsex)
132/// struct
133#[repr(C)]
134pub struct INITCOMMONCONTROLSEX {
135	dwSize: u32,
136	pub icc: co::ICC,
137}
138
139impl_default!(INITCOMMONCONTROLSEX, dwSize);
140
141/// [`LITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-litem)
142/// struct.
143#[repr(C)]
144pub struct LITEM {
145	pub mask: co::LIF,
146	pub iLink: i32,
147	pub state: co::LIS,
148	pub stateMask: co::LIS,
149	szID: [u16; MAX_LINKID_TEXT],
150	szUrl: [u16; L_MAX_URL_LENGTH],
151}
152
153impl_default!(LITEM);
154
155impl LITEM {
156	pub_fn_string_arr_get_set!(szID, set_szID);
157	pub_fn_string_arr_get_set!(szUrl, set_szUrl);
158}
159
160/// [`LVBKIMAGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvbkimagew)
161/// struct.
162#[repr(C)]
163pub struct LVBKIMAGE<'a> {
164	pub uFlags: co::LVBKIF,
165	pub hbm: HBITMAP,
166	pszImage: *mut u16,
167	cchImageMax: u32,
168	pub xOffsetPercent: i32,
169	pub yOffsetPercent: i32,
170
171	_pszImage: PhantomData<&'a mut u16>,
172}
173
174impl_default!(LVBKIMAGE, 'a);
175
176impl<'a> LVBKIMAGE<'a> {
177	pub_fn_string_buf_get_set!('a, pszImage, set_pszImage, raw_pszImage, cchImageMax);
178}
179
180/// [`LVCOLUMN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvcolumnw)
181/// struct.
182#[repr(C)]
183pub struct LVCOLUMN<'a> {
184	pub mask: co::LVCF,
185	pub fmt: co::LVCFMT_C,
186	pub cx: i32,
187	pszText: *mut u16,
188	cchTextMax: i32,
189	pub iSubItem: i32,
190	pub iImage: i32,
191	pub iOrder: i32,
192	pub cxMin: i32,
193	pub cxDefault: i32,
194	pub cxIdeal: i32,
195
196	_pszText: PhantomData<&'a mut u16>,
197}
198
199impl_default!(LVCOLUMN, 'a);
200
201impl<'a> LVCOLUMN<'a> {
202	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
203}
204
205/// [`LVFINDINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvfindinfow)
206/// struct.
207#[repr(C)]
208pub struct LVFINDINFO<'a> {
209	pub flags: co::LVFI,
210	psz: *mut u16,
211	pub lParam: isize,
212	pub pt: POINT,
213	pub vkDirection: co::VK_DIR,
214
215	_psz: PhantomData<&'a mut u16>,
216}
217
218impl_default!(LVFINDINFO, 'a);
219
220impl<'a> LVFINDINFO<'a> {
221	pub_fn_string_ptr_get_set!('a, psz, set_psz);
222}
223
224/// [`LVFOOTERINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvfooterinfo)
225/// struct.
226#[repr(C)]
227pub struct LVFOOTERINFO<'a> {
228	pub mask: co::LVFF,
229	pszText: *mut u16,
230	cchTextMax: i32,
231	pub cItems: u32,
232
233	_pszText: PhantomData<&'a mut u16>,
234}
235
236impl_default!(LVFOOTERINFO, 'a);
237
238impl<'a> LVFOOTERINFO<'a> {
239	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
240}
241
242/// [`LVFOOTERITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvfooteritem)
243/// struct.
244#[repr(C)]
245pub struct LVFOOTERITEM<'a> {
246	pub mask: co::LVFIF,
247	pub iItem: i32,
248	pszText: *mut u16,
249	cchTextMax: i32,
250	pub state: co::LVFIS,
251	pub stateMask: co::LVFIS,
252
253	_pszText: PhantomData<&'a mut u16>,
254}
255
256impl_default!(LVFOOTERITEM, 'a);
257
258impl<'a> LVFOOTERITEM<'a> {
259	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
260}
261
262/// [`LVGROUP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvgroup)
263/// struct.
264#[repr(C)]
265pub struct LVGROUP<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
266	cbSize: u32,
267	pub mask: co::LVGF,
268	pszHeader: *mut u16,
269	cchHeader: i32,
270	pszFooter: *mut u16,
271	cchFooter: i32,
272	pub iGroupId: i32,
273	pub stateMask: co::LVGS,
274	pub state: co::LVGS,
275	pub uAlign: co::LVGA_FH,
276	pszSubtitle: *mut u16,
277	cchSubtitle: i32,
278	pszTask: *mut u16,
279	cchTask: i32,
280	pszDescriptionTop: *mut u16,
281	cchDescriptionTop: i32,
282	pszDescriptionBottom: *mut u16,
283	cchDescriptionBottom: i32,
284	pub iTitleImage: i32,
285	pub iExtendedImage: i32,
286	pub iFirstItem: i32,
287	pub cItems: u32,
288	pszSubsetTitle: *mut u16,
289	cchSubsetTitle: i32,
290
291	_pszHeader: PhantomData<&'a mut u16>,
292	_pszFooter: PhantomData<&'b mut u16>,
293	_pszSubtitle: PhantomData<&'c mut u16>,
294	_pszTask: PhantomData<&'d mut u16>,
295	_pszDescriptionTop: PhantomData<&'e mut u16>,
296	_pszDescriptionBottom: PhantomData<&'f mut u16>,
297	_pszSubsetTitle: PhantomData<&'g mut u16>,
298}
299
300impl_default!(LVGROUP, cbSize, 'a, 'b, 'c, 'd, 'e, 'f, 'g);
301
302impl<'a, 'b, 'c, 'd, 'e, 'f, 'g> LVGROUP<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
303	pub_fn_string_buf_get_set!('a, pszHeader, set_pszHeader, raw_pszHeader, cchHeader);
304	pub_fn_string_buf_get_set!('b, pszFooter, set_pszFooter, raw_pszFooter, cchFooter);
305	pub_fn_string_buf_get_set!('c, pszSubtitle, set_pszSubtitle, raw_pszSubtitle, cchSubtitle);
306	pub_fn_string_buf_get_set!('d, pszTask, set_pszTask, raw_pszTask, cchTask);
307	pub_fn_string_buf_get_set!('e, pszDescriptionTop, set_pszDescriptionTop, raw_pszDescriptionTop, cchDescriptionTop);
308	pub_fn_string_buf_get_set!('f, pszDescriptionBottom, set_pszDescriptionBottom, raw_pszDescriptionBottom, cchDescriptionBottom);
309	pub_fn_string_buf_get_set!('g, pszSubsetTitle, set_pszSubsetTitle, raw_pszSubsetTitle, cchSubsetTitle);
310}
311
312/// [`LVGROUPMETRICS`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvgroupmetrics)
313/// struct.
314#[repr(C)]
315pub struct LVGROUPMETRICS {
316	cbSize: u32,
317	pub mask: co::LVGMF,
318	pub Left: u32,
319	pub Top: u32,
320	pub Right: u32,
321	pub Bottom: u32,
322	pub crLeft: COLORREF,
323	pub crTop: COLORREF,
324	pub crRight: COLORREF,
325	pub crBottom: COLORREF,
326	pub crHeader: COLORREF,
327	pub crFooter: COLORREF,
328}
329
330impl_default!(LVGROUPMETRICS, cbSize);
331
332/// [`LVHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvhittestinfo)
333/// struct.
334#[repr(C)]
335#[derive(Default)]
336pub struct LVHITTESTINFO {
337	pub pt: POINT,
338	pub flags: co::LVHT,
339	pub iItem: i32,
340	pub iSubItem: i32,
341	pub iGroup: i32,
342}
343
344/// [`LVINSERTGROUPSORTED`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvinsertgroupsorted)
345/// struct.
346#[repr(C)]
347pub struct LVINSERTGROUPSORTED<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
348	pub pfnGroupCompare: Option<PFNLVGROUPCOMPARE>,
349	pub pvData: usize,
350	pub lvGroup: LVGROUP<'a, 'b, 'c, 'd, 'e, 'f, 'g>,
351}
352
353impl<'a, 'b, 'c, 'd, 'e, 'f, 'g> Default for LVINSERTGROUPSORTED<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
354	fn default() -> Self {
355		Self {
356			pfnGroupCompare: None,
357			pvData: 0,
358			lvGroup: LVGROUP::default(), // has cbSize, so we can't use impl_default_size macro
359		}
360	}
361}
362
363/// [`LVINSERTMARK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvinsertmark)
364/// struct.
365#[repr(C)]
366pub struct LVINSERTMARK {
367	cbSize: u32,
368	pub dwFlags: co::LVIM,
369	pub iItem: i32,
370	dwReserved: u32,
371}
372
373impl_default!(LVINSERTMARK);
374
375/// [`LVITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvitemw)
376/// struct.
377#[repr(C)]
378pub struct LVITEM<'a> {
379	pub mask: co::LVIF,
380	pub iItem: i32,
381	pub iSubItem: i32,
382	pub state: co::LVIS,
383	pub stateMask: co::LVIS,
384	pszText: *mut u16,
385	cchTextMax: i32,
386	pub iImage: i32,
387	pub lParam: isize,
388	pub iIndent: i32,
389	pub iGroupId: co::LVI_GROUPID,
390	pub cColumns: u32,
391	pub puColumns: *mut i32,
392	pub piColFmt: *mut co::LVCFMT_I,
393	pub iGroup: i32,
394
395	_pszText: PhantomData<&'a mut u16>,
396}
397
398impl_default!(LVITEM, 'a);
399
400impl<'a> LVITEM<'a> {
401	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
402}
403
404/// [`LVITEMINDEX`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvitemindex)
405/// struct.
406#[repr(C)]
407#[derive(Default, Clone, Copy, PartialEq, Eq)]
408pub struct LVITEMINDEX {
409	pub iItem: i32,
410	pub iGroup: i32,
411}
412
413/// [`LVSETINFOTIP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvsetinfotip)
414/// struct.
415#[repr(C)]
416pub struct LVSETINFOTIP<'a> {
417	cbSize: u32,
418	pub dwFlags: u32, // unspecified
419	pszText: *mut u16,
420	pub iItem: i32,
421	pub iSubItem: i32,
422
423	_pszText: PhantomData<&'a mut u16>,
424}
425
426impl_default!(LVSETINFOTIP, cbSize, 'a);
427
428impl<'a> LVSETINFOTIP<'a> {
429	pub_fn_string_ptr_get_set!('a, pszText, set_pszText);
430}
431
432/// [`LVTILEINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvtileinfo)
433/// struct.
434#[repr(C)]
435pub struct LVTILEINFO<'a> {
436	cbSize: u32,
437	pub iItem: i32,
438	cColumns: u32,
439	puColumns: *mut u32,
440	piColFmt: *mut co::LVCFMT_C,
441
442	_puColumns: PhantomData<&'a mut u32>,
443}
444
445impl_default!(LVTILEINFO, cbSize, 'a);
446
447impl<'a> LVTILEINFO<'a> {
448	/// Returns the `puColumns` field.
449	#[must_use]
450	pub const fn puColumns(&self) -> Option<&'a mut [u32]> {
451		unsafe {
452			match self.puColumns.as_mut() {
453				Some(_) => Some(std::slice::from_raw_parts_mut(self.puColumns, self.cColumns as _)),
454				None => None,
455			}
456		}
457	}
458
459	/// Returns the `piColFmt` field.
460	#[must_use]
461	pub const fn piColFmt(&self) -> Option<&'a mut [co::LVCFMT_C]> {
462		unsafe {
463			match self.puColumns.as_mut() {
464				Some(_) => Some(std::slice::from_raw_parts_mut(self.piColFmt, self.cColumns as _)),
465				None => None,
466			}
467		}
468	}
469
470	/// Sets the `puColumns` and `piColFmt` fields.
471	///
472	/// # Panics
473	///
474	/// Panics if `puColumns` and `piColFmt` slices have different lengths.
475	pub fn set_puColumns_piColFmt(&mut self, val: Option<(&'a mut [u32], &'a mut [co::LVCFMT_C])>) {
476		if let Some(val) = val {
477			if val.0.len() != val.1.len() {
478				panic!("Different slice lengths: {} and {}.", val.0.len(), val.1.len());
479			}
480			self.cColumns = val.0.len() as _;
481			self.puColumns = val.0.as_mut_ptr();
482			self.piColFmt = val.1.as_mut_ptr();
483		} else {
484			self.cColumns = 0;
485			self.puColumns = std::ptr::null_mut();
486			self.piColFmt = std::ptr::null_mut();
487		}
488	}
489}
490
491/// [`LVTILEVIEWINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvtileviewinfo)
492/// struct.
493#[repr(C)]
494pub struct LVTILEVIEWINFO {
495	cbSize: u32,
496	pub dwMask: co::LVTVIM,
497	pub dwFlags: co::LVTVIF,
498	pub sizeTile: SIZE,
499	pub cLines: i32,
500	pub rcLabelMargin: RECT,
501}
502
503impl_default!(LVTILEVIEWINFO, cbSize);
504
505/// [`MCGRIDINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-mcgridinfo)
506/// struct.
507#[repr(C)]
508pub struct MCGRIDINFO<'a> {
509	cbSize: u32,
510	pub dwPart: co::MCGIP,
511	pub dwFlags: co::MCGIF,
512	pub iCalendar: i32,
513	pub iRow: i32,
514	pub iCol: i32,
515	bSelected: BOOL,
516	pub stStart: SYSTEMTIME,
517	pub stEnd: SYSTEMTIME,
518	pub rc: RECT,
519	pszName: *mut u16,
520	cchName: usize,
521
522	_pszName: PhantomData<&'a mut u16>,
523}
524
525impl_default!(MCGRIDINFO, cbSize, 'a);
526
527impl<'a> MCGRIDINFO<'a> {
528	pub_fn_bool_get_set!(bSelected, set_bSelected);
529	pub_fn_string_buf_get_set!('a, pszName, set_pszName, raw_pszName, cchName);
530}
531
532/// [`MCHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-mchittestinfo)
533/// struct.
534#[repr(C)]
535pub struct MCHITTESTINFO {
536	cbSize: u32,
537	pub pt: POINT,
538	pub uHit: co::MCHT,
539	pub st: SYSTEMTIME,
540	pub rc: RECT,
541	pub iOffset: i32,
542	pub iRow: i32,
543	pub iCol: i32,
544}
545
546impl_default!(MCHITTESTINFO, cbSize);
547
548/// [`MONTHDAYSTATE`](https://learn.microsoft.com/en-us/windows/win32/controls/monthdaystate)
549/// struct.
550#[repr(transparent)]
551#[derive(Default, Clone, Copy, PartialEq, Eq)]
552pub struct MONTHDAYSTATE(u32);
553
554impl MONTHDAYSTATE {
555	/// Returns the state of the bit corresponding to the given day index.
556	///
557	/// # Panics
558	///
559	/// Panics if `index` is greater than 31.
560	#[must_use]
561	pub fn get_day(&self, index: u8) -> bool {
562		if index > 31 {
563			panic!("MONTHDAYSTATE max index is 31, tried to get {}.", index)
564		} else {
565			((self.0 >> index) & 1) != 0
566		}
567	}
568
569	/// Sets the state of the bit corresponding to the given day index.
570	///
571	/// # Panics
572	///
573	/// Panics if `index` is greater than 31.
574	pub fn set_day(&mut self, index: u8, state: bool) {
575		if index > 31 {
576			panic!("MONTHDAYSTATE max index is 31, tried to set {}.", index)
577		} else if state {
578			self.0 |= 1 << index;
579		} else {
580			self.0 &= !(1 << index);
581		}
582	}
583}
584
585/// [`NMBCDROPDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmbcdropdown)
586/// struct.
587#[repr(C)]
588pub struct NMBCDROPDOWN {
589	pub hdr: NMHDR,
590	pub rcButton: RECT,
591}
592
593/// [`NMBCHOTITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmbchotitem)
594/// struct.
595#[repr(C)]
596pub struct NMBCHOTITEM {
597	pub hdr: NMHDR,
598	pub dwFlags: co::HICF,
599}
600
601/// [`NMCHAR`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmchar)
602/// struct.
603#[repr(C)]
604pub struct NMCHAR {
605	pub hdr: NMHDR,
606	pub ch: u32,
607	pub dwItemPrev: u32,
608	pub dwItemNext: u32,
609}
610
611/// [`NMCUSTOMDRAW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmcustomdraw)
612/// struct.
613#[repr(C)]
614pub struct NMCUSTOMDRAW {
615	pub hdr: NMHDR,
616	pub dwDrawStage: co::CDDS,
617	pub hdc: HDC,
618	pub rc: RECT,
619	pub dwItemSpec: usize,
620	pub uItemState: co::CDIS,
621	pub lItemlParam: isize,
622}
623
624/// [`NMDATETIMECHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimechange)
625/// struct.
626#[repr(C)]
627pub struct NMDATETIMECHANGE {
628	pub nmhdr: NMHDR,
629	pub dwFlags: co::GDT,
630	pub st: SYSTEMTIME,
631}
632
633/// [`NMDATETIMEFORMAT`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimeformatw)
634/// struct.
635#[repr(C)]
636pub struct NMDATETIMEFORMAT<'a> {
637	pub nmhdr: NMHDR,
638	pszFormat: *mut u16,
639	pub st: SYSTEMTIME,
640	pszDisplay: *mut u16,
641	szDisplay: [u16; 64], // used as a buffer to pszDisplay
642
643	_pszFormat: PhantomData<&'a mut u16>,
644}
645
646impl_default!(NMDATETIMEFORMAT, 'a);
647
648impl<'a> NMDATETIMEFORMAT<'a> {
649	pub_fn_string_ptr_get_set!('a, pszFormat, set_pszFormat);
650
651	/// Returns the `pszDisplay` field.
652	#[must_use]
653	pub fn pszDisplay(&self) -> String {
654		unsafe { WString::from_wchars_nullt(self.pszDisplay) }.to_string()
655	}
656
657	/// Sets the `pszDisplay` field.
658	pub fn set_pszDisplay(&mut self, text: &str) {
659		WString::from_str(text).copy_to_slice(&mut self.szDisplay);
660	}
661}
662
663/// [`NMDATETIMEFORMATQUERY`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimeformatqueryw)
664/// struct.
665#[repr(C)]
666pub struct NMDATETIMEFORMATQUERY<'a> {
667	pub nmhdr: NMHDR,
668	pszFormat: *mut u16,
669	pub szMax: SIZE,
670
671	_pszFormat: PhantomData<&'a mut u16>,
672}
673
674impl_default!(NMDATETIMEFORMATQUERY, 'a);
675
676impl<'a> NMDATETIMEFORMATQUERY<'a> {
677	pub_fn_string_ptr_get_set!('a, pszFormat, set_pszFormat);
678}
679
680/// [`NMDATETIMESTRING`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimestringw)
681/// struct.
682#[repr(C)]
683pub struct NMDATETIMESTRING<'a> {
684	pub nmhdr: NMHDR,
685	pszUserString: *mut u16,
686	pub st: SYSTEMTIME,
687	pub dwFlags: co::GDT,
688
689	_pszUserString: PhantomData<&'a mut u16>,
690}
691
692impl_default!(NMDATETIMESTRING, 'a);
693
694impl<'a> NMDATETIMESTRING<'a> {
695	pub_fn_string_ptr_get_set!('a, pszUserString, set_pszUserString);
696}
697
698/// [`NMDATETIMEWMKEYDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimewmkeydownw)
699/// struct.
700#[repr(C)]
701pub struct NMDATETIMEWMKEYDOWN<'a> {
702	pub nmhdr: NMHDR,
703	pub nVirtKey: i32,
704	pszFormat: *mut u16,
705	pub st: SYSTEMTIME,
706
707	_pszFormat: PhantomData<&'a mut u16>,
708}
709
710impl_default!(NMDATETIMEWMKEYDOWN, 'a);
711
712impl<'a> NMDATETIMEWMKEYDOWN<'a> {
713	pub_fn_string_ptr_get_set!('a, pszFormat, set_pszFormat);
714}
715
716/// [`NMDAYSTATE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdaystate)
717/// struct.
718#[repr(C)]
719pub struct NMDAYSTATE<'a> {
720	pub nmhdr: NMHDR,
721	pub stStart: SYSTEMTIME,
722	cDayState: i32,
723	prgDayState: *mut MONTHDAYSTATE,
724
725	_prgDayState: PhantomData<&'a mut MONTHDAYSTATE>,
726}
727
728impl_default!(NMDAYSTATE, 'a);
729
730impl<'a> NMDAYSTATE<'a> {
731	pub_fn_array_buf_get_set!('a, prgDayState, set_prgDayState, cDayState, MONTHDAYSTATE);
732}
733
734/// [`NMHDDISPINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmhddispinfow)
735/// struct.
736#[repr(C)]
737pub struct NMHDDISPINFO<'a> {
738	pub hdr: NMHDR,
739	pub iItem: i32,
740	pub mask: co::HDI,
741	pszText: *mut u16,
742	cchTextMax: i32,
743	pub iImage: i32,
744	pub lParam: isize,
745
746	_pszText: PhantomData<&'a mut u16>,
747}
748
749impl_default!(NMHDDISPINFO, 'a);
750
751impl<'a> NMHDDISPINFO<'a> {
752	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
753}
754
755/// [`NMHDFILTERBTNCLICK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmhdfilterbtnclick)
756/// struct.
757#[repr(C)]
758pub struct NMHDFILTERBTNCLICK {
759	pub hdr: NMHDR,
760	pub iItem: i32,
761	pub rc: RECT,
762}
763
764impl_default!(NMHDFILTERBTNCLICK);
765
766/// [`NMHDR`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-nmhdr)
767/// struct.
768#[repr(C)]
769#[derive(PartialEq, Eq)]
770pub struct NMHDR {
771	/// A window handle to the control sending the message.
772	pub hwndFrom: HWND,
773	idFrom: usize,
774	/// Notification code sent in
775	/// [`WM_NOTIFY`](https://learn.microsoft.com/en-us/windows/win32/controls/wm-notify).
776	pub code: NmhdrCode,
777}
778
779impl_default!(NMHDR);
780
781impl NMHDR {
782	/// Returns the `idFrom` field, the ID of the control sending the message.
783	#[must_use]
784	pub const fn idFrom(&self) -> u16 {
785		self.idFrom as _
786	}
787
788	/// Sets the `idFrom` field, the ID of the control sending the message.
789	pub const fn set_idFrom(&mut self, val: u16) {
790		self.idFrom = val as _
791	}
792}
793
794/// Notification code returned in [`NMHDR`](crate::NMHDR) struct. This code is
795/// convertible to/from the specific common control notification codes –
796/// [`LVN`](crate::co::LVN), [`TVN`](crate::co::TVN), etc.
797///
798/// # Examples
799///
800/// ```no_run
801/// use winsafe::{self as w, prelude::*, co};
802///
803/// // Convert LVN to NmhrCode:
804/// let code = w::NmhdrCode::from(co::LVN::ITEMCHANGED);
805///
806/// // Convert NmhrCode to LVN – fails it code is not a valid LVN:
807/// let lvn = co::LVN::try_from(code)?;
808/// # w::SysResult::Ok(())
809/// ```
810#[repr(transparent)]
811#[derive(Default, Clone, Copy, PartialEq, Eq)]
812pub struct NmhdrCode(i32);
813
814impl From<i32> for NmhdrCode {
815	fn from(v: i32) -> Self {
816		Self(v)
817	}
818}
819
820impl PartialOrd for NmhdrCode {
821	fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
822		self.0.partial_cmp(&other.0)
823	}
824}
825impl Ord for NmhdrCode {
826	fn cmp(&self, other: &Self) -> std::cmp::Ordering {
827		self.0.cmp(&other.0)
828	}
829}
830
831impl std::fmt::Display for NmhdrCode {
832	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
833		write!(f, "{}", self.0)
834	}
835}
836
837impl NmhdrCode {
838	#[must_use]
839	pub(crate) const fn from_code(v: i32) -> Self {
840		Self(v)
841	}
842
843	/// Returns the primitive integer underlying value.
844	///
845	/// This method is similar to [`Into`](std::convert::Into), but it is
846	/// `const`, therefore it can be used in
847	/// [const contexts](https://doc.rust-lang.org/reference/const_eval.html).
848	#[must_use]
849	pub const fn raw(&self) -> i32 {
850		self.0
851	}
852}
853
854/// [`NMHEADER`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmheaderw)
855/// struct.
856#[repr(C)]
857pub struct NMHEADER<'a> {
858	pub hdr: NMHDR,
859	pub iItem: i32,
860	pub iButton: i32,
861	pitem: *mut HDITEM<'a>,
862
863	_pitem: PhantomData<&'a mut HDITEM<'a>>,
864}
865
866impl_default!(NMHEADER, 'a);
867
868impl<'a> NMHEADER<'a> {
869	pub_fn_ptr_get_set!('a, pitem, set_pitem, HDITEM<'a>);
870}
871
872/// [`NMITEMACTIVATE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmitemactivate)
873/// struct.
874#[repr(C)]
875pub struct NMITEMACTIVATE {
876	pub hdr: NMHDR,
877	pub iItem: i32,
878	pub iSubItem: i32,
879	pub uNewState: co::LVIS,
880	pub uOldState: co::LVIS,
881	pub uChanged: co::LVIF,
882	pub ptAction: POINT,
883	pub lParam: isize,
884	pub uKeyFlags: co::LVKF,
885}
886
887/// [`NMOBJECTNOTIFY`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmobjectnotify)
888/// struct.
889#[repr(C)]
890pub struct NMOBJECTNOTIFY<'a> {
891	pub hdr: NMHDR,
892	pub iItem: i32,
893	piid: *mut co::IID,
894	Object: COMPTR,
895	pub hrResult: co::HRESULT,
896	pub dwFlags: u32,
897
898	_piid: PhantomData<&'a mut co::IID>,
899}
900
901impl_default!(NMOBJECTNOTIFY, 'a);
902impl_drop_comptr!(Object, NMOBJECTNOTIFY, 'a);
903
904impl<'a> NMOBJECTNOTIFY<'a> {
905	pub_fn_ptr_get_set!('a, piid, set_piid, co::IID);
906	pub_fn_comptr_get_set!(Object, set_Object, ole_IUnknown);
907}
908
909/// [`NMIPADDRESS`](https://learn.microsoft.com/en-us/windows/win32/api/Commctrl/ns-commctrl-nmipaddress)
910/// struct.
911#[repr(C)]
912pub struct NMIPADDRESS {
913	pub hdr: NMHDR,
914	pub iField: i32,
915	pub iValue: i32,
916}
917
918/// [`NMLINK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlink)
919/// struct.
920#[repr(C)]
921pub struct NMLINK {
922	pub hdr: NMHDR,
923	pub item: LITEM,
924}
925
926/// [`NMLISTVIEW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlistview)
927/// struct.
928#[repr(C)]
929pub struct NMLISTVIEW {
930	pub hdr: NMHDR,
931	pub iItem: i32,
932	pub iSubItem: i32,
933	pub uNewState: co::LVIS,
934	pub uOldState: co::LVIS,
935	pub uChanged: co::LVIF,
936	pub ptAction: POINT,
937	pub lParam: isize,
938}
939
940/// [`NMLVCACHEHINT`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvcachehint)
941/// struct.
942#[repr(C)]
943pub struct NMLVCACHEHINT {
944	pub hdr: NMHDR,
945	pub iFrom: i32,
946	pub iTo: i32,
947}
948
949/// [`NMLVCUSTOMDRAW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvcustomdraw)
950/// struct.
951#[repr(C)]
952pub struct NMLVCUSTOMDRAW {
953	pub mcd: NMCUSTOMDRAW,
954	pub clrText: COLORREF,
955	pub clrTextBk: COLORREF,
956	pub iSubItem: i32,
957	pub dwItemType: co::LVCDI,
958	pub clrFace: COLORREF,
959	pub iIconEffect: i32,
960	pub iIconPhase: i32,
961	pub iPartId: i32,
962	pub iStateId: i32,
963	pub rcText: RECT,
964	pub uAlign: co::LVGA_HEADER,
965}
966
967/// [`NMLVDISPINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvdispinfow)
968/// struct.
969#[repr(C)]
970pub struct NMLVDISPINFO<'a> {
971	pub hdr: NMHDR,
972	pub item: LVITEM<'a>,
973}
974
975/// [`NMLVEMPTYMARKUP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvemptymarkup)
976/// struct.
977#[repr(C)]
978pub struct NMLVEMPTYMARKUP {
979	pub hdr: NMHDR,
980	pub dwFlags: co::EMF,
981	szMarkup: [u16; L_MAX_URL_LENGTH],
982}
983
984impl_default!(NMLVEMPTYMARKUP);
985
986impl NMLVEMPTYMARKUP {
987	pub_fn_string_arr_get_set!(szMarkup, set_szMarkup);
988}
989
990/// [`NMLVFINDITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvfinditemw)
991/// struct.
992#[repr(C)]
993pub struct NMLVFINDITEM<'a> {
994	pub hdr: NMHDR,
995	pub iStart: i32,
996	pub lvfi: LVFINDINFO<'a>,
997}
998
999/// [`NMLVGETINFOTIP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvgetinfotipw)
1000/// struct.
1001#[repr(C)]
1002pub struct NMLVGETINFOTIP<'a> {
1003	pub hdr: NMHDR,
1004	pub dwFlags: co::LVGIT,
1005	pszText: *mut u16,
1006	cchTextMax: i32,
1007	pub iItem: i32,
1008	pub iSubItem: i32,
1009	pub lParam: isize,
1010
1011	_pszText: PhantomData<&'a mut u16>,
1012}
1013
1014impl_default!(NMLVGETINFOTIP, 'a);
1015
1016impl<'a> NMLVGETINFOTIP<'a> {
1017	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
1018}
1019
1020/// [`NMLVKEYDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvkeydown)
1021/// struct.
1022#[repr(C)]
1023pub struct NMLVKEYDOWN {
1024	pub hdr: NMHDR,
1025	pub wVKey: co::VK,
1026	flags: u32,
1027}
1028
1029impl_default!(NMLVKEYDOWN);
1030
1031/// [`NMLVLINK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvlink)
1032/// struct.
1033#[repr(C)]
1034pub struct NMLVLINK {
1035	pub hdr: NMHDR,
1036	pub link: LITEM,
1037	pub iItem: i32,
1038	pub iSubItem: i32,
1039}
1040
1041/// [`NMLVODSTATECHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvodstatechange)
1042/// struct.
1043#[repr(C)]
1044pub struct NMLVODSTATECHANGE {
1045	pub hdr: NMHDR,
1046	pub iFrom: i32,
1047	pub iTo: i32,
1048	pub uNewState: co::LVIS,
1049	pub uOldState: co::LVIS,
1050}
1051
1052/// [`NMLVSCROLL`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvscroll)
1053/// struct.
1054#[repr(C)]
1055pub struct NMLVSCROLL {
1056	pub hdr: NMHDR,
1057	pub dx: i32,
1058	pub dy: i32,
1059}
1060
1061/// [`NMMOUSE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmmouse)
1062/// struct.
1063#[repr(C)]
1064pub struct NMMOUSE {
1065	pub hdr: NMHDR,
1066	pub dwItemSpec: usize,
1067	pub dwItemData: usize,
1068	pub pt: POINT,
1069	pub dwHitInfo: isize,
1070}
1071
1072/// [`NMTRBTHUMBPOSCHANGING`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtrbthumbposchanging)
1073/// struct.
1074#[repr(C)]
1075pub struct NMTRBTHUMBPOSCHANGING {
1076	pub hdr: NMHDR,
1077	pub dwPos: u32,
1078	pub nReason: co::TB,
1079}
1080
1081/// [`NMSELCHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmselchange)
1082/// struct.
1083#[repr(C)]
1084pub struct NMSELCHANGE {
1085	pub nmhdr: NMHDR,
1086	pub stSelStart: SYSTEMTIME,
1087	pub stSelEnd: SYSTEMTIME,
1088}
1089
1090/// [`NMTCKEYDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtckeydown)
1091/// struct.
1092#[repr(C)]
1093pub struct NMTCKEYDOWN {
1094	pub hdr: NMHDR,
1095	pub wVKey: co::VK,
1096	pub flags: u32,
1097}
1098
1099impl_default!(NMTCKEYDOWN);
1100
1101/// [`NMTREEVIEW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtreevieww)
1102/// struct.
1103#[repr(C)]
1104pub struct NMTREEVIEW<'a, 'b> {
1105	pub hdr: NMHDR,
1106	pub action: u32, // actual type varies
1107	pub itemOld: TVITEM<'a>,
1108	pub itemNew: TVITEM<'b>,
1109	pub ptDrag: POINT,
1110}
1111
1112/// [`NMTVCUSTOMDRAW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtvcustomdraw)
1113/// stuct.
1114#[repr(C)]
1115pub struct NMTVCUSTOMDRAW {
1116	pub nmcd: NMCUSTOMDRAW,
1117	pub clrText: COLORREF,
1118	pub clrTextBk: COLORREF,
1119	pub iLevel: i32,
1120}
1121
1122/// [`NMTVITEMCHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtvitemchange)
1123/// struct.
1124#[repr(C)]
1125pub struct NMTVITEMCHANGE {
1126	pub hdr: NMHDR,
1127	pub uChanged: co::TVIF,
1128	pub hItem: HTREEITEM,
1129	pub uStateNew: co::TVIS,
1130	pub uStateOld: co::TVIS,
1131	pub lParam: isize,
1132}
1133
1134/// [`NMUPDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmupdown)
1135/// struct.
1136#[repr(C)]
1137pub struct NMUPDOWN {
1138	pub hdr: NMHDR,
1139	pub iPos: i32,
1140	pub iDelta: i32,
1141}
1142
1143/// [`NMVIEWCHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmviewchange)
1144/// struct.
1145#[repr(C)]
1146pub struct NMVIEWCHANGE {
1147	pub nmhdr: NMHDR,
1148	pub dwOldView: co::MCMV,
1149	pub dwNewView: co::MCMV,
1150}
1151
1152/// [`PBRANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-pbrange)
1153/// struct.
1154#[repr(C)]
1155#[derive(Default, Clone, Copy, PartialEq, Eq)]
1156pub struct PBRANGE {
1157	pub iLow: i32,
1158	pub iHigh: i32,
1159}
1160
1161/// [`PROPSHEETHEADER`](https://learn.microsoft.com/en-us/windows/win32/controls/pss-propsheetheader)
1162/// struct.
1163#[repr(C)]
1164pub struct PROPSHEETHEADER<'a, 'b, 'c, 'd, 'e, 'f> {
1165	dwSize: u32,
1166	pub dwFlags: co::PSH,
1167	pub hwndParent: HWND,
1168	pub hInstance: HINSTANCE,
1169	hIcon_pszIcon: *mut std::ffi::c_void, // union
1170	pszCaption: *mut u16,
1171	pub nPages: u32,
1172	union0: PROPSHEETHEADER_union0,
1173	ppsp_phpage: *mut std::ffi::c_void, // union,
1174	pub pfnCallback: Option<PFNPROPSHEETCALLBACK>,
1175	hbmWatermark_pszbmWatermark: *mut std::ffi::c_void, // union
1176	pub hplWatermark: HPALETTE,
1177	hbmHeader_pszbmHeader: *mut std::ffi::c_void, // union
1178
1179	_pszIcon: PhantomData<&'a u16>,
1180	_pszTitle: PhantomData<&'b mut u16>,
1181	_pStartPage: PhantomData<&'c mut u16>,
1182	_ppsp_phpage: PhantomData<&'d [PROPSHEETPAGE<'d, 'd, 'd, 'd, 'd, 'd, 'd>]>,
1183	_pszbmWatermark: PhantomData<&'e mut u16>,
1184	_pszbmHeader: PhantomData<&'f mut u16>,
1185}
1186
1187#[repr(C)]
1188union PROPSHEETHEADER_union0 {
1189	nStartPage: u32,
1190	pStartPage: *const u16,
1191}
1192
1193impl_default!(PROPSHEETHEADER, dwSize, 'a, 'b, 'c, 'd, 'e, 'f);
1194
1195impl<'a, 'b, 'c, 'd, 'e, 'f> PROPSHEETHEADER<'a, 'b, 'c, 'd, 'e, 'f> {
1196	/// Sets the `hIcon` field, which is part of an union.
1197	pub const fn set_hIcon(&mut self, hicon: HICON) {
1198		self.hIcon_pszIcon = hicon.ptr();
1199	}
1200
1201	/// Sets the `pszIcon` field, which is part of an union.
1202	pub fn set_pszIcon(&mut self, buf: &'a mut IdStr) {
1203		self.hIcon_pszIcon = match buf {
1204			IdStr::Id(id) => *id as _,
1205			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1206		};
1207	}
1208
1209	pub_fn_string_ptr_get_set!('b, pszCaption, set_pszCaption);
1210
1211	/// Sets the `nStartPage` field, which is part of an union.
1212	pub const fn set_nStartPage(&mut self, n: u32) {
1213		self.union0.nStartPage = n;
1214	}
1215
1216	/// Sets the `pStartPage` field, which is part of an union.
1217	pub fn set_pStartPage(&mut self, buf: &'c mut WString) {
1218		self.union0.pStartPage = unsafe { buf.as_mut_ptr() } as _;
1219	}
1220
1221	/// Sets the `ppsp` field, which is part of an union.
1222	pub const fn set_ppsp(&mut self, pages: &'d [PROPSHEETPAGE]) {
1223		self.ppsp_phpage = pages as *const _ as _;
1224	}
1225
1226	/// Sets the `phpage` field, which is part of an union.
1227	pub const fn set_phpage(&mut self, pages: &'d [HPROPSHEETPAGE]) {
1228		self.ppsp_phpage = pages as *const _ as _;
1229	}
1230
1231	/// Sets the `hbmWatermark` field, which is part of an union.
1232	pub const fn set_hbmWatermark(&mut self, hbm: HBITMAP) {
1233		self.hbmWatermark_pszbmWatermark = hbm.ptr();
1234	}
1235
1236	/// Sets the `pszbmWatermark` field, which is part of an union.
1237	pub fn set_pszbmWatermark(&mut self, buf: &'e mut IdStr) {
1238		self.hbmWatermark_pszbmWatermark = match buf {
1239			IdStr::Id(id) => *id as _,
1240			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1241		};
1242	}
1243
1244	/// Sets the `hbmHeader` field, which is part of an union.
1245	pub const fn set_hbmHeader(&mut self, hbm: HBITMAP) {
1246		self.hbmHeader_pszbmHeader = hbm.ptr();
1247	}
1248
1249	/// Sets the `pszbmHeader` field, which is part of an union.
1250	pub fn set_pszbmHeader(&mut self, buf: &'f mut IdStr) {
1251		self.hbmHeader_pszbmHeader = match buf {
1252			IdStr::Id(id) => *id as _,
1253			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1254		};
1255	}
1256}
1257
1258/// [`PROPSHEETPAGE`](https://learn.microsoft.com/en-us/windows/win32/controls/pss-propsheetpage)
1259/// struct.
1260#[repr(C)]
1261pub struct PROPSHEETPAGE<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
1262	dwSize: u32,
1263	pub dwFlags: co::PSP,
1264	pub hInstance: HINSTANCE,
1265	pszTemplate_pResource: *mut std::ffi::c_void, // union
1266	hIcon_pszIcon: *mut std::ffi::c_void,         // union
1267	pszTitle: *mut u16,
1268	pub pfnDlgProc: Option<DLGPROC>,
1269	pub lParam: isize,
1270	pub pfnCallback: Option<LPFNPSPCALLBACK>,
1271	pcRefParent: *mut u32,
1272	pszHeaderTitle: *mut u16,
1273	pszHeaderSubTitle: *mut u16,
1274	pub hActCtx: *mut std::ffi::c_void,
1275	hbmHeader_pszbmHeader: *mut std::ffi::c_void, // union
1276
1277	_pszTemplate: PhantomData<&'a mut u16>,
1278	_pszIcon: PhantomData<&'b mut u16>,
1279	_pszTitle: PhantomData<&'c mut u16>,
1280	_pcRefParent: PhantomData<&'d mut u32>,
1281	_pszHeaderTitle: PhantomData<&'e mut u16>,
1282	_pszHeaderSubTitle: PhantomData<&'f mut u16>,
1283	_pszbmHeader: PhantomData<&'g u16>,
1284}
1285
1286impl_default!(PROPSHEETPAGE, dwSize, 'a, 'b, 'c, 'd, 'e, 'f, 'g);
1287
1288impl<'a, 'b, 'c, 'd, 'e, 'f, 'g> PROPSHEETPAGE<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
1289	/// Sets the `pszTemplate` field, which is part of an union.
1290	pub fn set_pszTemplate(&mut self, buf: &'a mut IdStr) {
1291		self.pszTemplate_pResource = match buf {
1292			IdStr::Id(id) => *id as _,
1293			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1294		};
1295	}
1296
1297	/// Sets the `pResource` field, which is part of an union.
1298	pub const fn set_pResource(&mut self, r: &DLGTEMPLATE) {
1299		self.pszTemplate_pResource = r as *const _ as _;
1300	}
1301
1302	/// Sets the `hIcon` field, which is part of an union.
1303	pub const fn set_hIcon(&mut self, hicon: HICON) {
1304		self.hIcon_pszIcon = hicon.ptr();
1305	}
1306
1307	/// Sets the `pszIcon` field, which is part of an union.
1308	pub fn set_pszIcon(&mut self, buf: &'b mut IdStr) {
1309		self.hIcon_pszIcon = match buf {
1310			IdStr::Id(id) => *id as _,
1311			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1312		};
1313	}
1314
1315	pub_fn_string_ptr_get_set!('c, pszTitle, set_pszTitle);
1316
1317	/// Sets the `pcRefParent` field.
1318	pub const fn set_pcRefParent(&mut self, ref_count: &'d mut u32) {
1319		self.pcRefParent = ref_count;
1320	}
1321
1322	pub_fn_string_ptr_get_set!('e, pszHeaderTitle, set_pszHeaderTitle);
1323	pub_fn_string_ptr_get_set!('f, pszHeaderSubTitle, set_pszHeaderSubTitle);
1324
1325	/// Sets the `hbmHeader` field, which is part of an union.
1326	pub const fn set_hbmHeader(&mut self, hbm: HBITMAP) {
1327		self.hbmHeader_pszbmHeader = hbm.ptr();
1328	}
1329
1330	/// Sets the `pszbmHeader` field, which is part of an union.
1331	pub fn set_pszbmHeader(&mut self, buf: &'g mut IdStr) {
1332		self.hbmHeader_pszbmHeader = match buf {
1333			IdStr::Id(id) => *id as _,
1334			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1335		};
1336	}
1337}
1338
1339/// [`TBADDBITMAP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbaddbitmap)
1340/// struct.
1341#[repr(C)]
1342pub struct TBADDBITMAP {
1343	hInst: HINSTANCE,
1344	nID: usize,
1345}
1346
1347impl_default!(TBADDBITMAP);
1348
1349impl TBADDBITMAP {
1350	/// Returns the `hInst` and `nID` fields.
1351	#[must_use]
1352	pub fn nID(&self) -> BmpIdbRes {
1353		if self.hInst.ptr() as isize == HINST_COMMCTRL {
1354			BmpIdbRes::Idb(unsafe { co::IDB::from_raw(self.nID) })
1355		} else if self.hInst == HINSTANCE::NULL {
1356			BmpIdbRes::Bmp(unsafe { HBITMAP::from_ptr(self.nID as _) })
1357		} else {
1358			unsafe { BmpIdbRes::Res(IdStr::from_ptr(self.nID as _), self.hInst.raw_copy()) }
1359		}
1360	}
1361
1362	/// Sets the `hInst` and `nID` fields.
1363	pub fn set_nID(&mut self, val: &BmpIdbRes) {
1364		*self = match val {
1365			BmpIdbRes::Idb(idb) => Self {
1366				hInst: unsafe { HINSTANCE::from_ptr(HINST_COMMCTRL as _) },
1367				nID: idb.raw(),
1368			},
1369			BmpIdbRes::Bmp(bmp) => Self {
1370				hInst: HINSTANCE::NULL,
1371				nID: bmp.ptr() as _,
1372			},
1373			BmpIdbRes::Res(res, hInst) => Self {
1374				hInst: unsafe { hInst.raw_copy() },
1375				nID: res.as_ptr() as _,
1376			},
1377		}
1378	}
1379}
1380
1381/// [`TBBUTTON`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbbutton)
1382/// struct.
1383#[repr(C)]
1384pub struct TBBUTTON<'a> {
1385	pub iBitmap: i32,
1386	pub idCommand: i32,
1387	pub fsState: co::TBSTATE,
1388	pub fsStyle: co::BTNS,
1389	bReserved: [u8; 6], // assumes 64-bit architecture
1390	pub dwData: usize,
1391	iString: isize,
1392
1393	_iString: PhantomData<&'a mut u16>,
1394}
1395
1396impl_default!(TBBUTTON, 'a);
1397
1398impl<'a> TBBUTTON<'a> {
1399	/// Returns the `iString` field.
1400	#[must_use]
1401	pub fn iString(&self) -> IdxStr {
1402		if IS_INTRESOURCE(self.iString as _) {
1403			IdxStr::Idx(self.iString as _)
1404		} else {
1405			IdxStr::Str(unsafe { WString::from_wchars_nullt(self.iString as _) })
1406		}
1407	}
1408
1409	/// Sets the `iString` field.
1410	pub fn set_iString(&mut self, val: &'a mut IdxStr) {
1411		self.iString = match val {
1412			IdxStr::Idx(i) => *i as _,
1413			IdxStr::Str(s) => unsafe { s.as_mut_ptr() as _ },
1414		};
1415	}
1416}
1417
1418/// [`TBBUTTONINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbbuttoninfow)
1419/// struct.
1420#[repr(C)]
1421pub struct TBBUTTONINFO<'a> {
1422	cbSize: u32,
1423	pub dwMask: co::TBIF,
1424	pub idCommand: i32,
1425	pub iImage: i32,
1426	pub fsState: co::TBSTATE,
1427	pub fsStyle: co::BTNS,
1428	pub cx: u16,
1429	pub lParam: usize,
1430	pszText: *mut u16,
1431	cchText: i32,
1432
1433	_pszText: PhantomData<&'a mut u16>,
1434}
1435
1436impl_default!(TBBUTTONINFO, cbSize, 'a);
1437
1438impl<'a> TBBUTTONINFO<'a> {
1439	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchText);
1440}
1441
1442/// [`TBINSERTMARK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbinsertmark)
1443/// struct.
1444#[repr(C)]
1445#[derive(Default)]
1446pub struct TBINSERTMARK {
1447	pub iButton: i32,
1448	pub dwFlags: co::TBIMHT,
1449}
1450
1451/// [`TBMETRICS`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbmetrics)
1452/// struct.
1453#[repr(C)]
1454pub struct TBMETRICS {
1455	cbSize: u32,
1456	pub dwMask: co::TBMF,
1457	pub cxPad: i32,
1458	pub cyPad: i32,
1459	pub cxBarPad: i32,
1460	pub cyBarPad: i32,
1461	pub cxButtonSpacing: i32,
1462	pub cyButtonSpacing: i32,
1463}
1464
1465impl_default!(TBMETRICS, cbSize);
1466
1467/// [`TBREPLACEBITMAP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbreplacebitmap)
1468/// struct.
1469#[repr(C)]
1470pub struct TBREPLACEBITMAP {
1471	hInstOld: HINSTANCE,
1472	nIDOld: usize,
1473	hInstNew: HINSTANCE,
1474	nIDNew: usize,
1475	pub nButtons: i32,
1476}
1477
1478impl_default!(TBREPLACEBITMAP);
1479
1480impl TBREPLACEBITMAP {
1481	/// Returns the `hInstOld` and `nIDOld` fields.
1482	#[must_use]
1483	pub fn olds(&self) -> BmpInstId {
1484		if self.hInstOld == HINSTANCE::NULL {
1485			BmpInstId::Bmp(unsafe { HBITMAP::from_ptr(self.nIDOld as _) })
1486		} else {
1487			BmpInstId::InstId(unsafe { self.hInstOld.raw_copy() }, self.nIDOld as _)
1488		}
1489	}
1490
1491	/// Sets the `hInstOld` and `nIDOld` fields.
1492	pub fn set_olds(&mut self, val: BmpInstId) {
1493		match val {
1494			BmpInstId::Bmp(hbmp) => {
1495				self.hInstOld = HINSTANCE::NULL;
1496				self.nIDOld = hbmp.ptr() as _;
1497			},
1498			BmpInstId::InstId(hinst, id) => {
1499				self.hInstOld = hinst;
1500				self.nIDOld = id as _;
1501			},
1502		}
1503	}
1504
1505	/// Returns the `hInstNew` and `nIDNew` fields.
1506	#[must_use]
1507	pub fn news(&self) -> BmpInstId {
1508		if self.hInstNew == HINSTANCE::NULL {
1509			BmpInstId::Bmp(unsafe { HBITMAP::from_ptr(self.nIDNew as _) })
1510		} else {
1511			BmpInstId::InstId(unsafe { self.hInstNew.raw_copy() }, self.nIDNew as _)
1512		}
1513	}
1514
1515	/// Sets the `hInstNew` and `nIDNew` fields.
1516	pub fn set_news(&mut self, val: BmpInstId) {
1517		match val {
1518			BmpInstId::Bmp(hbmp) => {
1519				self.hInstNew = HINSTANCE::NULL;
1520				self.nIDNew = hbmp.ptr() as _;
1521			},
1522			BmpInstId::InstId(hinst, id) => {
1523				self.hInstNew = hinst;
1524				self.nIDNew = id as _;
1525			},
1526		}
1527	}
1528}
1529
1530/// [`TCHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tchittestinfo)
1531/// struct.
1532#[repr(C)]
1533pub struct TCHITTESTINFO {
1534	pub pt: POINT,
1535	pub flags: co::TCHT,
1536}
1537
1538impl_default!(TCHITTESTINFO);
1539
1540/// [`TCITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tcitemw)
1541/// struct.
1542#[repr(C)]
1543pub struct TCITEM<'a> {
1544	pub mask: co::TCIF,
1545	pub dwState: co::TCIS,
1546	pub dwStateMask: co::TCIS,
1547	pszText: *mut u16,
1548	cchTextMax: i32,
1549	pub iImage: i32,
1550	pub lParam: isize,
1551
1552	_pszText: PhantomData<&'a mut u16>,
1553}
1554
1555impl_default!(TCITEM, 'a);
1556
1557impl<'a> TCITEM<'a> {
1558	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
1559}
1560
1561/// [`TVHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvhittestinfo)
1562/// struct.
1563#[repr(C)]
1564pub struct TVHITTESTINFO {
1565	pub pt: POINT,
1566	pub flags: co::TVHT,
1567	pub hitem: HTREEITEM,
1568}
1569
1570/// [`TVINSERTSTRUCT`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvinsertstructw)
1571/// struct.
1572#[repr(C)]
1573pub struct TVINSERTSTRUCT<'a> {
1574	pub hParent: HTREEITEM,
1575	hInsertAfter: isize,
1576	pub itemex: TVITEMEX<'a>,
1577}
1578
1579impl_default!(TVINSERTSTRUCT, 'a);
1580
1581impl<'a> TVINSERTSTRUCT<'a> {
1582	/// Returns the `hInsertAfter` field.
1583	#[must_use]
1584	pub fn hInsertAfter(&self) -> TreeitemTvi {
1585		TreeitemTvi::from_isize(self.hInsertAfter)
1586	}
1587
1588	/// Sets the `hInsertAfter` field.
1589	pub fn set_hInsertAfter(&mut self, val: TreeitemTvi) {
1590		self.hInsertAfter = val.into();
1591	}
1592}
1593
1594/// [`TVITEMEX`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvitemexw)
1595/// struct.
1596#[repr(C)]
1597pub struct TVITEMEX<'a> {
1598	pub mask: co::TVIF,
1599	pub hItem: HTREEITEM,
1600	pub state: co::TVIS,
1601	pub stateMask: co::TVIS,
1602	pszText: *mut u16,
1603	cchTextMax: i32,
1604	pub iImage: i32,
1605	pub iSelectedImage: i32,
1606	pub cChildren: i32,
1607	pub lParam: isize,
1608	pub iIntegral: i32,
1609	pub uStateEx: co::TVIS_EX,
1610	hwnd: HWND,
1611	pub iExpandedImage: i32,
1612	iReserved: i32,
1613
1614	_pszText: PhantomData<&'a mut u16>,
1615}
1616
1617impl_default!(TVITEMEX, 'a);
1618
1619impl<'a> TVITEMEX<'a> {
1620	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
1621}
1622
1623/// [`TVITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvitemw)
1624/// struct.
1625#[repr(C)]
1626pub struct TVITEM<'a> {
1627	pub mask: co::TVIF,
1628	pub hItem: HTREEITEM,
1629	pub state: co::TVIS,
1630	pub stateMask: co::TVIS,
1631	pszText: *mut u16,
1632	cchTextMax: i32,
1633	pub iImage: i32,
1634	pub iSelectedImage: i32,
1635	pub cChildren: i32,
1636	pub lParam: isize,
1637
1638	_pszText: PhantomData<&'a mut u16>,
1639}
1640
1641impl_default!(TVITEM, 'a);
1642
1643impl<'a> TVITEM<'a> {
1644	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
1645}
1646
1647/// [`TVSORTCB`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvsortcb)
1648/// struct.
1649#[repr(C)]
1650pub struct TVSORTCB {
1651	pub hParent: HTREEITEM,
1652	pub lpfnCompare: Option<PFNTVCOMPARE>,
1653	pub lParam: isize,
1654}
1655
1656impl_default!(TVSORTCB);
1657
1658/// [`UDACCEL`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-udaccel)
1659/// struct.
1660#[repr(C)]
1661#[derive(Default)]
1662pub struct UDACCEL {
1663	pub nSec: u32,
1664	pub nInc: u32,
1665}